//各种Button类
//============================================================================================================================================
class ButtonEx extends Button {

    object = null;

    onStart() {
        this.onClick = () => {
            //console.log(this.gameObject.id);
            core.getObjectById("GameSystem").getBehaviour(GameEventSystem).excuteEvent(this.gameObject.id);
        }
    }
}

class BeginButton extends ButtonEx {

    @SerializedField('')
    url = './data/scenes/gameScene1.json';


    onStart() {

        gameProcess.mp3Player();


        this.onClick = () => {
            core.getObjectById("back").visible = true;
            core.getObjectById("notice").visible = true;
            core.getObjectById("beginGameButton").visible = false;
            core.getObjectById("CreditButton").visible = false;
            setTimeout(() => {
                core.changeScene(this.url);
            }, 3000);

            //console.log("!!!");

            gameProcess.audio.autoplay = true;
            gameProcess.audio.play();

        }

    }
}

class CreditButton extends ButtonEx {


    onStart() {
        this.onClick = () => {
            core.getObjectById("ProducerName").visible = !core.getObjectById("ProducerName").visible;
            core.getObjectById("titleImage").visible = !core.getObjectById("titleImage").visible;

            console.log("!!!");
        }
    }
}

class ProceeListButton extends ButtonEx {
    onStart() {
        this.onClick = () => {
            core.getObjectById('BeginGameSystem').getBehaviour(UIChangeCenter).changeUI("displayProducer");
        }
    }
}

class MemberButton extends ButtonEx {

    id: String;
    isChoosed: boolean = false;

    getCharacterID() {

        this.id = this.gameObject.id;
        //console.log(this.id);
        return this.id;

    }

    showAbility() {


        const name = core.getObjectById(this.getCharacterID()).getBehaviour(Character).characterName;
        const codeAbility = core.getObjectById(this.getCharacterID()).getBehaviour(Character).codeAbility;
        const artAbility = core.getObjectById(this.getCharacterID()).getBehaviour(Character).artAbility;
        const mathAbility = core.getObjectById(this.getCharacterID()).getBehaviour(Character).mathAbility;
        const lazy = core.getObjectById(this.getCharacterID()).getBehaviour(Character).lazy;
        const cost = core.getObjectById(this.getCharacterID()).getBehaviour(Character).cost;

        let word = '姓名:' + name + '\n' +
            '代码能力:' + codeAbility + '\n' +
            '美术能力:' + artAbility + '\n' +
            '数学能力:' + mathAbility + '\n' +
            '拖延症:' + lazy + '\n\n' +
            '花费:' + cost + '\n';

        core.getObjectById("infoWord").getBehaviour(WordRendererWithLines).word = word;
        core.getObjectById("infoButton").getBehaviour(InfoButton).thisMember = this.gameObject;

    }
}

class MemberToShow extends Behaviour {

    getAbility(member: Character) {
        const name = member.characterName;
        const codeAbility = member.codeAbility;
        const artAbility = member.artAbility;
        const mathAbility = member.mathAbility;

        let word = '姓名:' + name + '\n' +
            '代码能力:' + codeAbility + '\n' +
            '美术能力:' + artAbility + '\n' +
            '数学能力:' + mathAbility + '\n'
        core.getObjectById("memberDetailInfo").getBehaviour(WordRendererWithLines).word = word;
    }
    showAbility(key: string) {

        switch (key) {
            case "showMemberInfoButton_1":
                this.getAbility(myteam.members[0]);
                core.getObjectById("memberInfoImage").getBehaviour(Transform).x = 350;
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).x = 400;
                break;
            case "showMemberInfoButton_2":
                this.getAbility(myteam.members[1]);
                core.getObjectById("memberInfoImage").getBehaviour(Transform).x = 420;
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).x = 470;
                break;
            case "showMemberInfoButton_3":
                this.getAbility(myteam.members[2]);
                core.getObjectById("memberInfoImage").getBehaviour(Transform).x = 490;
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).x = 540;
                break;
            case "showMemberInfoButton_4":
                this.getAbility(myteam.members[3]);
                core.getObjectById("memberInfoImage").getBehaviour(Transform).x = 560;
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).x = 610;
                break;
        }
    }


}


class ProductionButton extends ButtonEx {
    id: String;


    getProductionrID() {

        this.id = this.gameObject.id;
        //console.log(this.id);
        return this.id;

    }
    showAttribute() {

        const productionType = core.getObjectById(this.getProductionrID()).getBehaviour(FinalProcuction).productionType;
        const codeDifficulty = core.getObjectById(this.getProductionrID()).getBehaviour(FinalProcuction).codeDifficulty;
        const artDifficulty = core.getObjectById(this.getProductionrID()).getBehaviour(FinalProcuction).artDifficulty;
        const mathDifficulty = core.getObjectById(this.getProductionrID()).getBehaviour(FinalProcuction).mathDifficulty;
        const productionDifficulty = core.getObjectById(this.getProductionrID()).getBehaviour(FinalProcuction).productionDifficulty;



        let word = '游戏类型:' + productionType + '\n' +
            '代码难度:' + codeDifficulty + '\n' +
            '美术难度:' + artDifficulty + '\n' +
            '数学难度:' + mathDifficulty + '\n' +
            '总体难度:' + productionDifficulty + '\n\n'

        core.getObjectById("infoWord").getBehaviour(WordRendererWithLines).word = word;
        core.getObjectById("infoButton2").getBehaviour(InfoButton2).thisProduction = this.gameObject;

    }
}

class InfoButton extends ButtonEx {

    thisMember = null;

    onUpdate() {
        if (this.thisMember) {
            if (this.thisMember.getBehaviour(Character).isChoosed) {
                this.image = "./image/按钮/还是算了.png";
            } else {
                this.image = "./image/按钮/就是你了.png";
            }
        }
    }
}

class InfoButton2 extends ButtonEx {

    thisProduction = null;

    onUpdate() {
        super.onUpdate();
        if (this.thisProduction) {
            if (this.thisProduction.getBehaviour(FinalProcuction).isChoosed) {
                this.image = "./image/按钮/还是算了.png";
            } else {
                this.image = "./image/按钮/就是你了.png";
            }
        }
    }
}

class ChooseButton extends ButtonEx {

    onUpdate() {

        super.onUpdate();
        if (this.gameObject.id == "chooseButton1") {
            const num = myteam.members.length;
            switch (num) {
                case 0:
                    this.image = "./image/按钮/还差4人.png";
                    break;
                case 1:
                    this.image = "./image/按钮/还差3人.png";
                    break;
                case 2:
                    this.image = "./image/按钮/还差2人.png";
                    break;
                case 3:
                    this.image = "./image/按钮/还差1人.png";
                    break;
                case 4:
                    this.image = "./image/按钮/选择完啦 有框.png";
                    break;
            };
        } else if (this.gameObject.id == "chooseButton2") {
            // const hasChosen=myteam.finalProduction.isChoosed;
            if (myteam.finalProduction != null) {
                this.image = "./image/按钮/选择完啦 有框.png";
            }
            else {
                this.image = "./image/按钮/还未选择.png";
            }

        }
    }
}

class ShowMembersToChooseButton extends ButtonEx {

    onStart() {
        this.onClick = () => {
            core.getObjectById('GameSystem').getBehaviour(UIChangeCenter).changeUI("MemberList");
            // console.log("choose a member");

        }
    }

}


//文字相关类
//===========================================================================================================================================

class WordRendererWithLines extends Behaviour {

    @SerializedField('')
    height = '';
    @SerializedField('black')
    color = 'black';
    @SerializedField('')
    word = '';

    onAddToGameObject() {
        this.gameObject.renderer = this;
    }

    onDraw(context) {

        context.save();
        //context.globalAlpha = this.$globalAlpha;
        context.font = this.height + 'px Arial';
        context.fillStyle = this.color;

        const texts = this.word.split("\n");
        for (let i = 0; i < texts.length; i++) {
            context.fillText(texts[i], 0, 0 + 20 * i);
        }

        context.restore();
    }

    hitTest(point) {

    }
}


//计算相关类
//==========================================================================================================================================
class AllCalculate extends Behaviour {  //所有计算公式

    calculateTeamInitHP() {                   // 计算初始团队士气值
        let allMemberHPCost = myteam.members[0].cost + myteam.members[1].cost + myteam.members[2].cost + myteam.members[3].cost;
        console.log("AllMemberCost: " + allMemberHPCost);
        let result = 80 + (myteam.initCount - allMemberHPCost) + myteam.finalProduction.productionDifficulty;
        core.getObjectById("powerCountText").getBehaviour(WordRenderer).word = result.toString();
        myteam.teamHP = result;

    }
    calculateTeamReduceHP() {
        gameProcess.questionToDo * 15
    }

    calculateTeamInitProcess(): number {            //计算第一天的进度
        let initProcess = myteam.teamProcess + 10;
        console.log("TeamProgress: " + initProcess);
        myteam.teamProcess = initProcess
        return initProcess;

    }

    DailyFixedHP() {                        //每日固定增加士气
        let allMemberHPCost = myteam.members[0].cost + myteam.members[1].cost + myteam.members[2].cost + myteam.members[3].cost;

        let recoverHP = 5 + (allMemberHPCost / 10);
        return recoverHP;
    }

    DailyFixedProcess() {        //每日固定增加进度

        return myteam.teamProcess + 25;
    }
    ifReduceProcess(ifReduce: boolean) {
        if (ifReduce === true) {
            return this.questionProcess();
        }
        else {
            return 0;
        }
    }

    questionProcess() {
        let whoSolvedID = gameProcess.recordQuestion.getBehaviour(Question).whoSolved
        let whoSolved = core.getObjectById(whoSolvedID)
        if (gameProcess.recordQuestion) {
            let questionType = gameProcess.recordQuestion.getBehaviour(Question).questionType;
            switch (questionType) {
                case "code":
                    let memberCodeAbility = whoSolved.getBehaviour(Character).codeAbility;
                    let codeDifficulty = myteam.finalProduction.codeDifficulty;
                    let reduce1 = (memberCodeAbility + codeDifficulty + (0.1 * myteam.teamHP)) * 0.5
                    return reduce1;

                case "art":
                    let memberArtAbility = whoSolved.getBehaviour(Character).codeAbility;
                    let artDifficulty = myteam.finalProduction.codeDifficulty;
                    let reduce2 = (memberArtAbility + artDifficulty + (0.1 * myteam.teamHP)) * 0.5
                    return reduce2;

                case "math":
                    let memberMathAbility = whoSolved.getBehaviour(Character).codeAbility;
                    let mathDifficulty = myteam.finalProduction.codeDifficulty;
                    let reduce3 = (memberMathAbility + mathDifficulty + (0.1 * myteam.teamHP)) * 0.5
                    return reduce3;

                case "other":
                    let lazy = whoSolved.getBehaviour(Character).lazy;
                    let reduce4 = (lazy + (0.1 * myteam.teamHP)) * 0.5
                    return reduce4;

            }
        }
        else {
            return 0;
        }
    }

    LazyProbability(x) {        //成员摸鱼的概率
        let probability = myteam.members[x].lazy * 10;
    }

    LazyResult() {              //摸鱼的奖励和惩罚
        let reduceProcess = myteam.teamDelay / 10;
        let process = myteam.teamProcess - reduceProcess;
        myteam.teamProcess = process;
        let addHp = myteam.teamDelay;
        let hp = myteam.teamHP + addHp;
        myteam.teamHP = hp;
    }


    getMemberInfo() {
        core.getObjectById("showMemberInfoButton_1").addChild(myteam.members[0].gameObject);
        core.getObjectById("showMemberInfoButton_2").addChild(myteam.members[1].gameObject);
        core.getObjectById("showMemberInfoButton_3").addChild(myteam.members[2].gameObject);
        core.getObjectById("showMemberInfoButton_4").addChild(myteam.members[3].gameObject);

        const image1 = core.getObjectById("showMemberInfoButton_1").children[0].getBehaviour(Character).imageUrl
        core.getObjectById("showMemberInfoButton_1").getBehaviour(ButtonEx).image = image1;

        const image2 = core.getObjectById("showMemberInfoButton_2").children[0].getBehaviour(Character).imageUrl
        core.getObjectById("showMemberInfoButton_2").getBehaviour(ButtonEx).image = image2;

        const image3 = core.getObjectById("showMemberInfoButton_3").children[0].getBehaviour(Character).imageUrl
        core.getObjectById("showMemberInfoButton_3").getBehaviour(ButtonEx).image = image3;

        const image4 = core.getObjectById("showMemberInfoButton_4").children[0].getBehaviour(Character).imageUrl
        core.getObjectById("showMemberInfoButton_4").getBehaviour(ButtonEx).image = image4;
        // console.log( core.getObjectById("showMemberInfoButton_1"));
    }



}



//GameRule类
//=========================================================================================================================================
class GameRule extends Behaviour {

    days = 1

    allCalculateResult = new AllCalculate();

    startAnimation = false;

    onStart() {

    }

    onUpdate() {
        this.days = gameProcess.days;
        const dateImage = core.getObjectById("date").getBehaviour(ImageRenderer);
        const dateText = core.getObjectById("everyDayText").getBehaviour(ImageRenderer);
        core.getObjectById("gameProgressPhoto").getBehaviour(HealthLineRenderer).hpNow = myteam.teamProcess;
        var count = 0;
        for (let i = 0; i < myteam.members.length; i++) {
            count = count + myteam.members[i].cost;
        }
        core.getObjectById("memberPointText").getBehaviour(WordRenderer).word = myteam.initCount - count;
        if (myteam.teamHP) {
            myteam.teamHP = Math.floor(myteam.teamHP);
            myteam.teamProcess = Math.floor(myteam.teamProcess);
            core.getObjectById("powerCountText").getBehaviour(WordRenderer).word = myteam.teamHP.toString();
            //console.log("12345:"+core.getObjectById("powerCountText").getBehaviour(WordRenderer).word);
            this.allCalculateResult.getMemberInfo();
            core.getObjectById("resultProcessText").getBehaviour(WordRenderer).word = myteam.teamProcess;
            core.getObjectById("resultPowerText").getBehaviour(WordRenderer).word = myteam.teamHP;
            core.getObjectById("dayProcessText").getBehaviour(WordRenderer).word = myteam.teamProcess;
            core.getObjectById("dayPowerText").getBehaviour(WordRenderer).word = myteam.teamHP;
        }
        //console.log("进度"+core.getObjectById("gameProgressPhoto").getBehaviour(HealthLineRenderer).hpNow);
        switch (this.days) {
            case 1:
                dateImage.image = "./image/日历/日历第一天.png";
                //dateText.image = "./image/文字/话术2.png";
                break;

            case 2:
                dateImage.image = "./image/日历/日历第二天.png";
                dateText.image = "./image/文字/话术2.png";
                break;
            case 3:
                dateImage.image = "./image/日历/日历第三天.png";
                dateText.image = "./image/文字/话术3.png";
                break;
            case 4:
            case 4.5:
                dateImage.image = "./image/日历/日历第四天.png";
                dateText.image = "./image/文字/话术6.png";
                break;
            case 5:
            case 5.5:
                dateImage.image = "./image/日历/日历第五天.png";
                break;
        }

        const children = core.getObjectById("todayQuestions").children;
        const images = core.getObjectById("QuestionDoneImages").children;
        const images1 = core.getObjectById("unChooseMemberImages").children;

        for (let i = 0; i < 4; i++) {
            if (children[i].object && children[i].object.getBehaviour(Question).isDone) {
                images[i].visible = true;
            } else {
                images[i].visible = false;
            }
        }


        for (let e of children) {
            const index = children.indexOf(e);
            if (e.object && e.object.getBehaviour(Question).isDone === false) {

                images1[index].visible = false;
            }

            if (this.startAnimation) {
                const left = core.getObjectById("leftPic").getBehaviour(Transform);
                const right = core.getObjectById("rightPic").getBehaviour(Transform);
                if (left.x !== -800 && right.x !== 800) {
                    left.x -= 5;
                    right.x += 5;
                } else {
                    this.startAnimation = false;
                    core.getObjectById("reviewImages").visible = false;
                    core.getObjectById("leftPic").getBehaviour(Transform).x = 0;
                    core.getObjectById("rightPic").getBehaviour(Transform).x = 0;
                }
            }
        }
    }



    /*准备阶段结束（选组员、选制作游戏的类型） */
    //------------------------------------------------------------------------------------------

    async passDay(changeUIBehaviour: UIChangeCenter) {


        this.days = gameProcess.getDays();
        if (this.days < 5) {
            await this.newDay(changeUIBehaviour);
        } else {
            this.lastDay();
        }
    }

    async newDay(changeUIBehaviour: UIChangeCenter) {
        if (myteam.teamHP < 0 || myteam.teamProcess < 0) {
            changeUIBehaviour.changeUI("ShanKuPaoLu");
        }
        else {
            changeUIBehaviour.changeUI("GameRule_newDay");

            gameProcess.setDays(1);
            this.days = gameProcess.getDays();

            gameProcess.isNewDay = true;



            this.newDayQuestions();
            gameProcess.allReduceProcess = 0;
            gameProcess.questionToDo = 4;
        }



    }
    whichQuestion(key: String) {
        switch (key) {
            case "todayQuestionButton_1":
                gameProcess.recordQuestion = core.getObjectById("todayQuestions").children[0].object;
                break;
            case "todayQuestionButton_2":
                gameProcess.recordQuestion = core.getObjectById("todayQuestions").children[1].object;
                break;
            case "todayQuestionButton_3":
                gameProcess.recordQuestion = core.getObjectById("todayQuestions").children[2].object;
                break;
            case "todayQuestionButton_4":
                gameProcess.recordQuestion = core.getObjectById("todayQuestions").children[3].object;
                break;
        }
    }

    TargetQuestion(key: String) {
        let targetQuestion
        switch (key) {
            case "todayQuestionButton_1":
                targetQuestion = core.getObjectById("todayQuestions").children[0].object;
                break;
            case "todayQuestionButton_2":
                targetQuestion = core.getObjectById("todayQuestions").children[1].object;
                break;
            case "todayQuestionButton_3":
                targetQuestion = core.getObjectById("todayQuestions").children[2].object;
                break;
            case "todayQuestionButton_4":
                targetQuestion = core.getObjectById("todayQuestions").children[3].object;
                break;

        }
        return targetQuestion;
    }
    InfoImagePos(key: String) {
        switch (key) {
            case "todayQuestionButton_1":

                core.getObjectById("chooseMemberImage").getBehaviour(Transform).y = 200;
                core.getObjectById("showMemberInfoButton_1").getBehaviour(Transform).y = 210;
                core.getObjectById("showMemberInfoButton_2").getBehaviour(Transform).y = 210;
                core.getObjectById("showMemberInfoButton_3").getBehaviour(Transform).y = 210;
                core.getObjectById("showMemberInfoButton_4").getBehaviour(Transform).y = 210;
                core.getObjectById("memberInfoImage").getBehaviour(Transform).y = 250
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).y = 350;

                gameProcess.recordQuestion = core.getObjectById("todayQuestionButton_1").object

                break;
            case "todayQuestionButton_2":

                core.getObjectById("chooseMemberImage").getBehaviour(Transform).y = 300;
                core.getObjectById("showMemberInfoButton_1").getBehaviour(Transform).y = 310;
                core.getObjectById("showMemberInfoButton_2").getBehaviour(Transform).y = 310;
                core.getObjectById("showMemberInfoButton_3").getBehaviour(Transform).y = 310;
                core.getObjectById("showMemberInfoButton_4").getBehaviour(Transform).y = 310;
                core.getObjectById("memberInfoImage").getBehaviour(Transform).y = 350
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).y = 450;
                gameProcess.recordQuestion = core.getObjectById("todayQuestionButton_2").object;
                break;
            case "todayQuestionButton_3":

                core.getObjectById("chooseMemberImage").getBehaviour(Transform).y = 400;
                core.getObjectById("showMemberInfoButton_1").getBehaviour(Transform).y = 410;
                core.getObjectById("showMemberInfoButton_2").getBehaviour(Transform).y = 410;
                core.getObjectById("showMemberInfoButton_3").getBehaviour(Transform).y = 410;
                core.getObjectById("showMemberInfoButton_4").getBehaviour(Transform).y = 410;
                core.getObjectById("memberInfoImage").getBehaviour(Transform).y = 450
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).y = 550;
                gameProcess.recordQuestion = core.getObjectById("todayQuestionButton_3").object
                break;
            case "todayQuestionButton_4":

                core.getObjectById("chooseMemberImage").getBehaviour(Transform).y = 500;
                core.getObjectById("showMemberInfoButton_1").getBehaviour(Transform).y = 510;
                core.getObjectById("showMemberInfoButton_2").getBehaviour(Transform).y = 510;
                core.getObjectById("showMemberInfoButton_3").getBehaviour(Transform).y = 510;
                core.getObjectById("showMemberInfoButton_4").getBehaviour(Transform).y = 510;
                core.getObjectById("memberInfoImage").getBehaviour(Transform).y = 300;
                core.getObjectById("memberDetailInfo").getBehaviour(Transform).y = 400;
                gameProcess.recordQuestion = core.getObjectById("todayQuestionButton_4").object
                break;
        }
    }

    newDayQuestions() {
        console.log("newDayQuestions")
        if (gameProcess.isNewDay) {
            gameProcess.isNewDay = false;
            gameProcess.confirmButtons = [];
            // for (let child of core.getObjectById("questions").children) {
            //     child.getBehaviour(Question).isDone = false;
            // }
            for (let i = 0; i < core.getObjectById("todayQuestions").children.length; i++) {
                //for (let e of core.getObjectById("todayQuestions").children) {
                let e = core.getObjectById("todayQuestions").children[i];
                e.object = core.getObjectById("questions").getBehaviour(AllQuestion).returnQuestion();
                e.object.getBehaviour(Question).hasChosen = true;
                e.object.getBehaviour(Question).isDone = false;
                //console.log(e.object);
                e.getBehaviour(ButtonEx).image = e.object.getBehaviour(Question).imageUrl;

                let confirmButton = core.getObjectById("confirmMissionButtons").children[i];
                confirmButton.getBehaviour(ButtonEx).object = e.object.getBehaviour(Question);
                gameProcess.confirmButtons.push(e.object.getBehaviour(Question));
            }
            console.log(core.getObjectById("todayQuestions").children);
            gameProcess.todayQuestions = core.getObjectById("todayQuestions").children;
        } else {
            core.getObjectById("todayQuestions").children = gameProcess.todayQuestions;
        }

    }


    getQuestionType() {
        process
    }
    getAnswerMemberInfo() {

    }
    ReInitDayQuestions() {
        for (let i = 0; i < core.getObjectById("confirmMissionButtons").children.length; i++) {
            const child = core.getObjectById("confirmMissionButtons").children[i];
            child.getBehaviour(ButtonEx).object = gameProcess.confirmButtons[i];
        }
    }

    deleteQuestions() {
        var question = new AllQuestion();
        for (let e of core.getObjectById("todayQuestions").children) {
            // question.removeQuestionFromList(e.children);
            // const thisQuestion=new TodayQuestions();
            e.object = null;
            // console.log(e.children);

        }
    }
    /*切换场景（小游戏） */
    //----------------------------------------------------------------------------------------
    changeToGame(type: string, num: number) {

        let number = num;
        const behaviour = core.getObjectById("questions").getBehaviour(LittleGame);

        switch (type) {
            case "code":
                gameProcess.setGameData(behaviour.hrdData.image, behaviour.hrdData["lowDifficulty"][number]);
                core.changeScene('./data/scenes/HuaRongDao.json');
                break;
            case "math":
                gameProcess.setGameData(behaviour.sdData.image, behaviour.sdData["lowDifficulty"][number]);
                core.changeScene('./data/scenes/shudu.json');
                break;
            case "art":
                gameProcess.setGameData(behaviour.zbtData.image, behaviour.zbtData["lowDifficulty"][number]);
                core.changeScene('./data/scenes/zhaobutong.json');
                break;
            case "other":
                gameProcess.setGameData(behaviour.txzData.image, behaviour.txzData["lowDifficulty"][number]);
                core.changeScene('./data/scenes/tuixiangzi.json');
                break;
        }
    }

    /*加班部分 */
    //-----------------------------------------------------------------------------------------

    async doMoreWork() {

        const changeUIBehaviour = this.gameObject.getBehaviour(UIChangeCenter);
        changeUIBehaviour.changeUI("GameRule_doMoreWork");
        gameProcess.isDoMoreWork = true;
        console.log("more work")
    }

    passDoMoreWork() {
        const changeUIBehaviour = this.gameObject.getBehaviour(UIChangeCenter);
        changeUIBehaviour.changeUI("GameRule_passDoMoreWork");

        if (gameProcess.isDoMoreWork) {
            gameProcess.setDays(0.5);
            this.days = gameProcess.days;
            this.reviewToday();
        } else {
            changeUIBehaviour.changeUI("GameRule_newDay");
        }
        console.log(this.days);


    }


    /*每日总结+最后一天 */
    //--------------------------------------------------------------------
    async lastDay() {
        const changeUIBehaviour = this.gameObject.getBehaviour(UIChangeCenter);
        changeUIBehaviour.changeUI("GameRule_lastDay");

        const image = core.getObjectById("ending").getBehaviour(ImageRenderer);
        const FinishWord = core.getObjectById("endingText").getBehaviour(ImageRenderer);
        const teamProcess = myteam.teamProcess;
        if (teamProcess >= 100) {
            image.image = "./image/结局/100完成度.png";
            FinishWord.image = "./image/文字/100完成度文字.png";
        } else if (teamProcess >= 80) {
            image.image = "./image/结局/80完成度.png";
            FinishWord.image = "./image/文字/80完成度文字.png";
        } else if (teamProcess >= 60) {
            image.image = "./image/结局/60完成度.png";
            FinishWord.image = "./image/文字/60完成度文字.png";
        } else {
            var num = Math.random() * 100;
            if (num < 5) {
                image.image = "./image/结局/大赦天下.png";
                FinishWord.image = "./image/文字/大赦天下.png";
            }else{
                image.image = "./image/结局/开发失败.png";
                FinishWord.image = "./image/文字/开发失败.png";
            }

        }
        console.log(teamProcess);
    }

    async reviewToday() {

        const changeUIBehaviour = this.gameObject.getBehaviour(UIChangeCenter);
        let everyQuestionReduceHP = 8//玩每个小游戏消耗的士气值
        let nodone = 9;//没做小游戏减少的进度

        myteam.teamHP = myteam.teamHP + this.allCalculateResult.DailyFixedHP() - (4 - gameProcess.questionToDo) * everyQuestionReduceHP;
        myteam.teamProcess = this.allCalculateResult.DailyFixedProcess() - gameProcess.allReduceProcess - gameProcess.questionToDo * nodone;
        console.log("今日减少士气值：" + (4 - gameProcess.questionToDo) * 15);
        console.log("今日减少进度：" + gameProcess.allReduceProcess);
        console.log("今日完成 " + (4 - gameProcess.questionToDo) + "个问题");
        changeUIBehaviour.hideChildren("chooseMemberToMisson");
        changeUIBehaviour.hideChildren("QuestionDoneImages");
        //changeUIBehaviour.hideChildren("questions");
        //console.log(this.days)
        changeUIBehaviour.changeUI("GameRule_reviewToday");
        // changeUIBehaviour.hideChildren("todayQuestionButton_1");
        // changeUIBehaviour.hideChildren("todayQuestionButton_2");
        // changeUIBehaviour.hideChildren("todayQuestionButton_3");
        // changeUIBehaviour.hideChildren("todayQuestionButton_4");
        // this.deleteQuestions();




        //加班
        if (this.days == 5) {
            this.doMoreWork();
        } else {
            core.getObjectById("reviewImages").visible = true;
            changeUIBehaviour.changeUI("GameRule_reviewToday_else");
            this.startAnimation = true;
        }


        //结束晚会

    }

    toEnding() {
        const changeUIBehaviour = this.gameObject.getBehaviour(UIChangeCenter);
        changeUIBehaviour.changeUI("GameRule_toEnding");
    }


}

class GameEventSystem extends Behaviour {

    excuteEvent(key: String) {
        const gameRule = this.gameObject.getBehaviour(GameRule);
        const changeUIBehaviour = this.gameObject.getBehaviour(UIChangeCenter);

        switch (key) {
            case "catelogButton":
                changeUIBehaviour.changeUI("catelogUI");
                changeUIBehaviour.changeUI("GameRule_chooseMembers");
                changeUIBehaviour.changeUI("GameRule_showMembersToChoose");
                break;
            case "member1":
            case "member2":
            case "member3":
            case "member4":
            case "member5":
            case "member6":
            case "member7":
            case "member8":
            case "member9":
            case "member10":
            case "member11":
            case "member12":
            case "member13":
            case "member14":
            case "member15":
                core.getObjectById(key).getBehaviour(MemberButton).showAbility();
                changeUIBehaviour.changeUI("showAbility");
                break;
            case "infoButton":
                const _this = core.getObjectById("infoButton").getBehaviour(InfoButton);
                if (!_this.thisMember.getBehaviour(Character).isChoosed) {
                    myteam.addMember(_this.thisMember.getBehaviour(Character));
                    _this.thisMember.getBehaviour(Character).isChoosed = true;
                    //console.log("this member is in your team");
                } else {
                    myteam.removeMember(_this.thisMember.getBehaviour(Character));
                    _this.thisMember.getBehaviour(Character).isChoosed = false;
                    console.log("this member isn't in your team now");
                }

                break;
            case "chooseButton1":
                if (myteam.members.length == 4) {
                    changeUIBehaviour.changeUI("Jiu_Shi_Ni_La_Button");
                    changeUIBehaviour.changeUI("chooseMembers");
                    changeUIBehaviour.hideChildren("allCharacters");
                }
                break;
            case "production1":
            case "production2":
            case "production3":
            case "production4":
            case "production5":
            case "production6":
            case "production7":
            case "production8":
            case "production9":
            case "production10":
                //console.log("22222222");
                core.getObjectById(key).getBehaviour(ProductionButton).showAttribute();
                changeUIBehaviour.changeUI("showDifficulty");
                break;
            case "infoButton2":
                const _this2 = core.getObjectById("infoButton2").getBehaviour(InfoButton2);
                if (!_this2.thisProduction.getBehaviour(FinalProcuction).isChoosed) {
                    // myteam.addMember(_this2.thisMember.getBehaviour(Character));
                    myteam.chooseFinalProduction(_this2.thisProduction.getBehaviour(FinalProcuction));
                    _this2.thisProduction.getBehaviour(FinalProcuction).isChoosed = true;
                    console.log("this production has been chosen");
                } else {
                    myteam.cancelChooseFinalProduction(_this2.thisProduction.getBehaviour(FinalProcuction));
                    _this2.thisProduction.getBehaviour(FinalProcuction).isChoosed = false;
                    console.log("this production hasn't been chosen");
                }

                break;
            case "chooseButton2":
                if (myteam.finalProduction != null) {
                    changeUIBehaviour.changeUI("chooseType");
                    gameRule.newDay(changeUIBehaviour);
                    //core.getObjectById("todayQuestions").getBehaviour(TodayQuestions).getRandomQuestions();



                    core.getObjectById("GameSystem").getBehaviour(AllCalculate).calculateTeamInitHP();
                    core.getObjectById("GameSystem").getBehaviour(AllCalculate).calculateTeamInitProcess();
                    core.getObjectById("questions").getBehaviour(AllQuestion)
                }
                break;


            case "showMemberInfoButton_1":
            case "showMemberInfoButton_2":
            case "showMemberInfoButton_3":
            case "showMemberInfoButton_4":

                changeUIBehaviour.changeUI("ChooseMember");
                core.getObjectById("memberDetailInfo").visible = true;
                core.getObjectById("memberDetailInfo").getBehaviour(MemberToShow).showAbility(key);
                gameProcess.recordQuestion.getBehaviour(Question).whoSolved = core.getObjectById(key).children[0].id;

                break;


            case "confirmMissionButton_1":
            case "confirmMissionButton_2":
            case "confirmMissionButton_3":
            case "confirmMissionButton_4":
                //gameRule.changeToGame();

                const target = core.getObjectById(key).getBehaviour(ButtonEx).object;
                if (target.whoSolved != "0" && !target.isDone && gameProcess.recordQuestion === target.gameObject) {
                    changeUIBehaviour.changeUI("ConfirmMission");
                    target.isDone = true;
                    gameRule.changeToGame(target.questionType, target.keyOfLittleGame);
                    gameProcess.recordQuestion = target.gameObject;
                    console.log("playgame");
                    console.log(core.getObjectById(key).getBehaviour(ButtonEx).object);
                    console.log(core.getObjectById(key).getBehaviour(ButtonEx).object.gameObject);
                }

                break;
            case "passDayButton":
                gameRule.reviewToday();
                myteam.teamProcess = Math.floor(myteam.teamProcess);
                myteam.teamHP = Math.floor(myteam.teamHP);
                core.getObjectById("dayProcessText").getBehaviour(WordRenderer).word = myteam.teamProcess;
                core.getObjectById("dayPowerText").getBehaviour(WordRenderer).word = myteam.teamHP;
                break;
            case "yesButton":
                changeUIBehaviour.changeUI("DoMoreWorkYes");
                changeUIBehaviour.changeUI("DoMoreWork");
                break;
            case "noButton":
                gameRule.passDoMoreWork();
                changeUIBehaviour.changeUI("DoMoreWork");
                break;
            case "codeButton":
                console.log("挑战了代码难题");
                gameRule.changeToGame("code", 0);
                //changeUIBehaviour.changeUI("Challenge");
                break;
            case "artButton":
                console.log("挑战了美术难题");
                changeUIBehaviour.changeUI("Challenge");
                gameRule.changeToGame("art", 0);
                break;
            case "mathButton":
                console.log("挑战了平衡难题");
                changeUIBehaviour.changeUI("Challenge");
                gameRule.changeToGame("math", 0);
                break;
            case "passMoreWorkButton":
                gameRule.passDoMoreWork();
                break;
            case "clearReviewButton":
                changeUIBehaviour.changeUI("clearReview");

                gameRule.passDay(changeUIBehaviour);
                break;
            case "clearResultButton":
                gameRule.toEnding();
                break;
            case "todayQuestionButton_1":
            case "todayQuestionButton_2":
            case "todayQuestionButton_3":
            case "todayQuestionButton_4":
                changeUIBehaviour.changeUI("MemberList");
                gameProcess.whichConfirm = gameRule.TargetQuestion(key);
                gameRule.InfoImagePos(key);
                gameRule.whichQuestion(key);
                break;


            default:
                console.log(key)
                break;
        }
    }
}


//每日任务问题相关类
//==========================================================================================================================================

class Question extends Behaviour {
    questionType: string = '';
    text: string = '';
    hasChosen: boolean = false;
    imageUrl
    keyOfLittleGame: string = '';
    isDone = false;
    whoSolved: string = "0";
    //confirmButton = null;

}

class AllQuestion extends Question {

    //texts = [];
    // todayTexts = [];
    questions = null;

    removeQuestionFromList(question: Question) {  //回答过问题后将问题从列表中删除
        const index = this.questions.indexOf(question);
        if (index >= 0) {
            this.questions.splice(index, 1);
        }
    }

    addQuestion() {

        for (let i of Object.keys(this.questions)) {

            const obj = new GameObject();
            const behaviour = new Question();
            const transform = new Transform();
            obj.id = this.questions[i].id;
            behaviour.questionType = this.questions[i].type;
            behaviour.text = this.questions[i].text;
            behaviour.imageUrl = this.questions[i].image;
            behaviour.keyOfLittleGame = this.questions[i].keyOfLittleGame;
            behaviour.whoSolved = this.questions[i].whoSolved;
            console.log(behaviour.imageUrl);
            obj.addBehaviour(transform);
            obj.addBehaviour(behaviour);
            this.gameObject.addChild(obj);
        }

    }

    getRandomQuestion() {
        const questions = this.gameObject.children;
        const question = questions[Math.floor(Math.random() * (questions.length))];
        return question;
    }


    returnQuestion() {
        let question = this.getRandomQuestion();
        while (question.getBehaviour(Question).hasChosen === true) {
            question = this.getRandomQuestion();
        }
        return question;
    }
}

// class TodayQuestions extends ButtonEx {

//     //questions = core.getObjectById("questions").children;



//     // getARandomQuestion() {

//     //     let singleQuestion = this.questions[Math.floor(Math.random() * (this.questions.length))];

//     //     // console.log(singleQuestion);

//     //     // singleQuestion.getBehaviour(Question).hasChosen=true;            
//     //     return singleQuestion;


//     // }

//     // returnAQuestion() {

//     //     let aQuestion = this.getARandomQuestion();
//     //     while (aQuestion.getBehaviour(Question).hasChosen === true) {
//     //         console.log(aQuestion.id + ":" + aQuestion.getBehaviour(Question).hasChosen);
//     //         aQuestion = this.getARandomQuestion();
//     //     }

//     //     return aQuestion;
//     // }


// }

class LittleGame extends Question {

    hrdData = null;
    txzData = null;
    sdData = null;
    zbtData = null;

    getGame() {

    }

    returnResult() {

    }


}



//UI_visible相关类
//============================================================================================================================================
class UIChangeCenter extends Behaviour {

    UIs = {
        "catelogUI": {
            'catelogImage': false,
            'catelog': false,
            'catelogButton': false,
            'catelogText': false

        },
        "chooseMembers": {
            "chooseMembersTitle": false,
            "memberPoint": false,
            "memberPointText": false,
            "chooseTypeTitle": true,
            "allCharacters": false,
            "infoButton": false,
            //"infoButton2":false,
            "productions": true,
            "info": false,
            'chooseButton1': false,
            'chooseButton2': true,
            "production1": true,
            "production2": true,
            "production3": true,
            "production4": true,
            "production5": true,
            "production6": true,
            "production7": true,
            "production8": true,
            "production9": true,
            "production10": true
        },
        "chooseType": {
            "chooseTypeTitle": false,
            'choose Members & Type': false,
            'chooseButton2': false,
            "allChoice": false,
            "production1": false
        },
        "clearReview": {
            "reviewBlackboard": false,
            "clearReviewButton": false,
            "reviewPartyWord": false,
            "reviewProcessWord": false,
            "reviewHPWord": false,
            "dayProcessText": false,
            "dayPowerText": false,
            "ComputerDecorate": false
        },
        "showAbility": {
            "info": true,
        },
        "showMemberDetails": {

        },
        "showDifficulty": {
            "info": true,
        },
        "DoMoreWorkYes": {
            "challengeButton": true,
            "codeButton": true,
            "artButton": true,
            "mathButton": true,
            "codePhoto": true,
            "artPhoto": true,
            "mathPhoto": true,
        },
        "DoMoreWork": {
            "yesButton": false,
            "noButton": false,
            "是否加班": false
        },
        "Challenge": {
            "chooseQuestionTypeTitle": false,
            "challengeButton": true,
            "codeButton": false,
            "artButton": false,
            "mathButton": false,
            "codePhoto": false,
            "artPhoto": false,
            "mathPhoto": false,
            "passMoreWorkButton": true,
            "moreWorkResult": true
        },
        "GameRule_chooseMembers": {
            'choose Members & Type': true,
            'chooseButton1': true,

        },
        "GameRule_showMembersToChoose": {
            "allCharacters": true
        },
        "GameRule_newDay": {
            "passDayButton": true,
            "everyday": true,
            "everyDayText": true,
            "infoButton2": false,
        },
        "GameRule_doMoreWork": {
            "moreWork": true,
            "是否加班": true,
            "yesButton": true,
            "noButton": true,
            "passMoreWorkButton": false,
            "moreWorkResult": false
        },
        "GameRule_passDoMoreWork": {
            "moreWork": false,
            "passMoreWorkButton": false,
            "moreWorkResult": false
        },
        "GameRule_lastDay": {
            "date": false,
            "passDayButton": false,
            "everyday": false,
            "clearReviewButton": false,
            "resultBlackboard": true,
            //"lastDayImage": true,
            //"comment": true,
            "clearResultButton": true,
            "gameResult": true,
            "gameResultDetail": true,
            "resultPowerText": true,
            "resultProcessText": true
        },
        "GameRule_reviewToday": {
            "passDayButton": false,
            "everyday": false
        },
        "GameRule_reviewToday_else": {
            "reviewBlackboard": true,
            "reviewHPWord": true,
            "clearReviewButton": true,
            "reviewPartyWord": true,
            "reviewProcessWord": true,
            "dayProcessText": true,
            "dayPowerText": true,
            "ComputerDecorate": true

        },
        "GameRule_toEnding": {
            "resultBlackboard": false,
            //"lastDayImage": false,
            //"comment": false,
            "clearResultButton": false,
            "gameResult": false,
            "gameResultDetail": false,
            "resultPowerText": false,
            "resultProcessText": false,
            "date": false,
            "ending": true,
            "endingDialog": true,
            "endingText": true
        },
        "MemberList": {
            'chooseMemberImage': true,
            'showMemberInfoButton_1': true,
            'showMemberInfoButton_2': true,
            'showMemberInfoButton_3': true,
            'showMemberInfoButton_4': true
        },
        "ConfirmMission": {
            'memberInfoImage': false,
            'chooseMemberImage': false,
            'showMemberInfoButton_1': false,

        },
        "ChooseMember": {
            'memberInfoImage': true

        },


        "Jiu_Shi_Ni_La_Button": {
            "infoButton2": true
        },

        "TodayQuestions": {
            "todayQuestionButton_1": false,
            "todayQuestionButton_2": false,
            "todayQuestionButton_3": false,
            "todayQuestionButton_4": false
        },
        "ShowMemberInfoButton_1": {
            "memberDetailInfo": true
        },
        "showProducer": {
            "ProducerName": true
        },
        "displayProducer": {
            "ProducerName": false
        },
        "ShanKuPaoLu": {
            "shankupaolu": true,
            "endingDialog": true,
            "shankupaoluWord": true,
            "date": false
        }


    }

    changeUI(type: string) {
        for (let id of Object.keys(this.UIs[type])) {
            core.getObjectById(id).visible = this.UIs[type][id];
        }
    }

    hideChildren(id: string) {
        if (core.getObjectById(id).children) {
            for (let child of core.getObjectById(id).children) {
                child.visible = false;
            }
        }
    }

    showChildren(id: string) {
        if (core.getObjectById(id).children) {
            for (let child of core.getObjectById(id).children) {
                child.visible = true;
            }
        }
    }
}



//游戏基础类
//=============================================================================================================================================
class Team {

    members: Character[] = [];
    teamHP: number;
    teamCodeAbility: number;
    teamArtAbility: number;
    teamDelay: number;



    finalProduction: FinalProcuction;//团队选择的要制作的游戏

    initCount = 100//团队初始点数
    teamProcess = 0;//团队初始进度

    addMember(member: Character) {//添加团队成员
        var count = 0;
        for (var i = 0; i < this.members.length; i++) {
            count = count + this.members[i].cost;
        }
        count = this.initCount - count;
        if (this.members.length < 4 && count >= member.cost) {
            this.members.push(member);
            console.log(this.members);
        } else {
            console.log("选择失败");
        }

    }

    removeMember(member: Character) {
        const index = this.members.indexOf(member);
        if (index !== -1) {
            this.members.splice(index, 1);
            console.log(this.members);
        }
    }

    chooseFinalProduction(finalProduction: FinalProcuction) {//选择要制作的游戏   
        finalProduction.isChoosed = true;
        this.finalProduction = finalProduction;
    }

    cancelChooseFinalProduction(finalProduction: FinalProcuction) {
        finalProduction.isChoosed = false;
        this.finalProduction = null;
    }
}

class GameProcess {

    days = 1;
    gameData = null;
    image = null;
    gameResult = null;
    todayQuestions = [];
    confirmButtons = [];
    isNewDay = true;
    isDoMoreWork = false;
    recordQuestion = null;
    whichConfirm = null
    allReduceProcess = 0
    questionToDo = 4
    audio = null;

    setGameResult(result: boolean) {
        const calculateReduceProcess = new AllCalculate();
        this.gameResult = result;
        if (this.gameResult === false) {
            this.allReduceProcess += calculateReduceProcess.ifReduceProcess(true)

        }
        else {
            this.allReduceProcess = calculateReduceProcess.ifReduceProcess(false)
            this.questionToDo -= 1;
        }

    }


    setGameData(image, gameData) {
        this.image = image;
        this.gameData = gameData;
    }

    setDays(number: number) {
        this.days += number;
    }

    getDays() {
        return this.days;
    }

    changeSceneBack(type: string) {
        const gameRule = core.getObjectById("GameSystem").getBehaviour(GameRule);
        const changeUIBehaviour = core.getObjectById("GameSystem").getBehaviour(UIChangeCenter);


        core.changeScene("./data/scenes/gameScene1.json");
        gameRule.days == this.days;
        //this.days = gameRule.days;

        switch (type) {
            case "morework":
                changeUIBehaviour.changeUI("catelogUI");
                changeUIBehaviour.changeUI("GameRule_doMoreWork");
                changeUIBehaviour.changeUI("DoMoreWork");
                changeUIBehaviour.changeUI("Challenge");
                break;
            // case "everyday":
            //     changeUIBehaviour.changeUI("catelogUI");
            //     changeUIBehaviour.changeUI("GameRule_reviewToday_else");
            //     break;
        }

        if (this.gameResult) {
            core.getObjectById("moreWorkResult").getBehaviour(ImageRenderer).image = "./image/文字/加班成功.png";
        } else {
            core.getObjectById("moreWorkResult").getBehaviour(ImageRenderer).image = "./image/文字/加班失败.png";

        }

        gameRule.newDayQuestions();
        gameRule.ReInitDayQuestions();
        CollisionDetectionSystem.gameType = "";


    }

    mp3Player() {

        const mp3 = "./image/main.mp3";
        this.audio = new Audio(mp3);
        this.audio.loop = true;
        this.audio.autoplay = false;
        //this.audio.play();
    }

}

class AllCharacters extends Behaviour {

    allCharacters = null;

    addCharacters() {
        console.log(this.allCharacters)
        const index = Object.keys(this.allCharacters);
        for (let i = 0; i < index.length; i++) {

            const id = "member" + (i + 1);
            const button = core.getObjectById(id).getBehaviour(MemberButton);
            const obj = core.getObjectById(id)

            const behaviour = new Character();
            behaviour.characterName = this.allCharacters[i].characterName;
            behaviour.characterName = this.allCharacters[i].characterName;
            behaviour.codeAbility = this.allCharacters[i].codeAbility;
            behaviour.artAbility = this.allCharacters[i].artAbility;
            behaviour.mathAbility = this.allCharacters[i].mathAbility;
            behaviour.lazy = this.allCharacters[i].lazy;
            behaviour.cost = this.allCharacters[i].cost;
            behaviour.imageUrl = this.allCharacters[i].imageUrl;
            button.image = this.allCharacters[i].image;

            obj.addBehaviour(behaviour);


        }

    }
}

class FinalProcuction extends Behaviour {//要制作的游戏
    @SerializedField('')
    productionType: string;
    @SerializedField(1)
    codeDifficulty: number;
    @SerializedField(1)
    artDifficulty: number;
    @SerializedField(1)
    mathDifficulty: number;
    @SerializedField(1)
    productionDifficulty: number;

    isChoosed = false;

    caluculateProductionDifficult() {
        return this.productionDifficulty = this.codeDifficulty + this.artDifficulty + this.mathDifficulty;
    }

}

class ReadFile extends Behaviour {

    //@SerializedField('')
    // questionsUrl: "./data/questions.json";
    //@SerializedField('')
    // membersUrl: "./data/members.json";


    onAddToGameObject() {
        this.getJsons();
    }


    onStart() {
        //this.getJsons();
    }

    async getJsons() {
        const questionsJson = await this._loadText("./data/questions.json");
        this.toQuestions(questionsJson);
        const membersJson = await this._loadText("./data/members.json");
        this.toMembers(membersJson);
        const hrdJson = await this._loadText("./data/HRDdata.json");
        this.toHRDGame(hrdJson);
        const txzJson = await this._loadText("./data/TXZdata.json");
        this.toTXZGame(txzJson);
        const zbtJson = await this._loadText("./data/ZBTdata.json");
        this.toZBTGame(zbtJson);
        const sdJson = await this._loadText("./data/SDdata.json");
        this.toSDGame(sdJson);
    }

    toQuestions(data: any) {
        core.getObjectById("questions").getBehaviour(AllQuestion).questions = data;
        core.getObjectById("questions").getBehaviour(AllQuestion).addQuestion();
    }

    toMembers(data: any) {
        core.getObjectById("allCharacters").getBehaviour(AllCharacters).allCharacters = data;
        core.getObjectById("allCharacters").getBehaviour(AllCharacters).addCharacters()
    }

    toHRDGame(data: any) {
        core.getObjectById("questions").getBehaviour(LittleGame).hrdData = data;

        //gameProcess.setGameData(data.image,data.lowDifficulty[0]);
    }

    toTXZGame(data: any) {
        core.getObjectById("questions").getBehaviour(LittleGame).txzData = data;
        //gameProcess.setGameData(data.image, data.lowDifficulty[0]);
    }

    toSDGame(data: any) {
        core.getObjectById("questions").getBehaviour(LittleGame).sdData = data;
        //临时
        //gameProcess.setGameData(data.image, data.lowDifficulty[0]);
    }

    toZBTGame(data: any) {
        core.getObjectById("questions").getBehaviour(LittleGame).zbtData = data;
        gameProcess.setGameData(data.image, data.lowDifficulty[0]);
    }

    async _loadText(url: string) {

        return new Promise((resolve, reject) => {
            const xhr = new XMLHttpRequest();
            xhr.open("GET", url);
            xhr.send();
            xhr.onload = () => {
                const text = xhr.responseText;
                const json = JSON.parse(text);
                //console.log(json)
                //return json;
                resolve(json);
            }
        })
    }
}


//============================================================================================================================================

const myteam = new Team()
const gameProcess = new GameProcess();

//===========================================================================================================================================
core.registerBehaviourClass(BeginButton);
core.registerBehaviourClass(CreditButton);
core.registerBehaviourClass(ButtonEx);
core.registerBehaviourClass(MemberButton);
core.registerBehaviourClass(InfoButton);
core.registerBehaviourClass(InfoButton2);
core.registerBehaviourClass(ChooseButton);
core.registerBehaviourClass(ShowMembersToChooseButton);
core.registerBehaviourClass(WordRendererWithLines);

core.registerBehaviourClass(ProceeListButton);

core.registerBehaviourClass(GameRule);
core.registerBehaviourClass(GameEventSystem);
core.registerBehaviourClass(UIChangeCenter);


//core.registerBehaviourClass(Process);
core.registerBehaviourClass(Team);
core.registerBehaviourClass(AllQuestion);
core.registerBehaviourClass(Question);
core.registerBehaviourClass(LittleGame);

core.registerBehaviourClass(FinalProcuction);
core.registerBehaviourClass(ProductionButton);
core.registerBehaviourClass(AllCalculate);


core.registerBehaviourClass(ReadFile);
core.registerBehaviourClass(AllCharacters);
//core.registerBehaviourClass(TodayQuestions);
core.registerBehaviourClass(MemberToShow);

